# -*- coding:UTF-8 -*-
"""
@Project : pythonProject
@File    : LoginTest.py
@IDE     : PyCharm
@Author  : WorldWind(1772830365@qq.com)
@Address : China - HeiLongjiang - Herbin
@Date    : 2025/7/7 下午8:33
"""
userInfo = [
    {'userAccount': 'Kate@qq.com', 'password': '123456'},
    {'userAccount': 'Mike@qq.com', 'password': '111111'}
]


def checkUser(username, password):
    for user in userInfo:
        if user['userAccount'] == username:
            if user['password'] == password:
                return 1  # 用户登录成功
            else:
                return -2  # 用户密码错误
    else:
        return -1  # 账号不存在


while 1:
    username = input("Please input your username:")
    if len(username) < 10 or ('@' and 'qq.com') not in username:
        print("The format of the username you entered is illegal! Please re-enter!")
        continue
    else:
        password = input("Please input your password:")
        if len(password) < 6:
            print("The format of the password you entered is illegal! Please re-enter!")
            continue
        else:
            data = checkUser(username, password)
            if data == 1:
                print("Welcome " + username + "!")
                break
            elif data == -1:
                print("The user account does not exist!")
            elif data == -2:
                print("User password error")
